<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Web Page Content"  ValidateRequest="false"  %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="ClubStarterKit.Web" %>
<%@ Import Namespace="SubSonic" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>



<script runat="server">
    Public Shared OrigionalContent As String = ""
    Public Shared IsNew as Boolean = False
        
    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If Not Page.IsPostBack Then
            If Request("sectionname") Is Nothing Then
                Response.Redirect("~/default.aspx")
            Else
                OrigionalContent = CMS.GetContent(Request.QueryString("sectionname").ToString())
                If OrigionalContent = "IsNotAdded" Then
                    FCKeditor1.Value = "<p></p>"
                    IsNew = True
                Else
                    FCKeditor1.Value = OrigionalContent
                    IsNew =False
                End If
            End If
        End If

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newcontent As String = ""
        If FCKeditor1.Value = "" Then
            newcontent = "<p></p>"
        Else
            newcontent = FCKeditor1.Value
        End If
        
        If OrigionalContent = "IsNotAdded" Or IsNew = True Then
            CMS.AddContent(Request.QueryString("sectionname").ToString(), newcontent)
        Else
            CMS.UpdateContent(Request.QueryString("sectionname").ToString(), newcontent)
        End If

        Dim ip As String = Request.ServerVariables("REMOTE_ADDR")
        If ClubStarterKit.Web.Settings.ReportCMS = True Then
            CMS.ReportUpdate(OrigionalContent, newcontent, Request.QueryString("sectionname").ToString(), ip)
        End If
        
        If Request("ReturnURL") Is Nothing = False Then
            Response.Redirect(CStr(Request("ReturnURL")))
        Else
            Response.Redirect("~/default.aspx")
        End If

    End Sub
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="fullwidth">
        <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="500px" Width="100%"
            ToolbarSet="Default" SkinPath="skins/office2003/" BasePath="~/FCKeditor/" UseBROnCarriageReturn="true" />
        <Club:RolloverButton ID="Button1" runat="server" Text="Update" />
    </div>
</asp:Content>
